{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "定义函数：\n",
    "1.写def: def 定义函数的第一步 2.写定义函数的名称：def function_name\n",
    "\n",
    "1.function_name 遵循变量名称定义的规则 3.函数名称后加上“（）：”def function_name(): ===> f(x) = 2x\n",
    "\n",
    "写一个实现hello word 的函数\n",
    "def hello():\n",
    "    '''打印hello world'''\n",
    "    print('hello world!')\n",
    "\n",
    "hello()\n",
    "hello world!\n",
    "help(fib)\n",
    "Help on function fib in module __main__:\n",
    "\n",
    "fib(n)\n",
    "    Print a Fibonacci series up to n.\n",
    "默认参数\n",
    "#zhichao\n",
    "\n",
    "def describe_pet(animal_type,pet_name):\n",
    "    \"\"\"显示宠物信息\"\"\"\n",
    "    print(\"\\nI have a \" + animal_type + \".\")\n",
    "    print(\"My \" + animal_type + \"'s name is \"+pet_name.title() + \".\")\n",
    "# 运行\n",
    "describe_pet('hamster','harry')\n",
    "describe_pet('cat','python')  #函数调用多次是一种效率极高的工作方式"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}